package com.jtjrenren.android.taxi.passenger.core.order.tip;

import android.app.Activity;
import android.content.Intent;

import com.jtjrenren.android.taxi.passenger.R;
import com.jtjrenren.android.taxi.passenger.base.BaseActivity;
import com.library.weidget.wheel.wheel.WheelView;
import com.library.weidget.wheel.wheel.adapter.NumberWheelAdapter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/2/15.
 */
public class OrderTipChooseActivity extends BaseActivity {
    public static String RETURN_VALUE = "value";
    private static int TIP_MAX = 51;

    @BindView(R.id.choose_tip_wheel)
    WheelView tips;

    public static Intent getDiyIntent(Activity activity, int tip){
        Intent intent=new Intent(activity,OrderTipChooseActivity.class);
        intent.putExtra("tip",tip);
        return intent;
    }

    @Override
    public int getLayoutId() {
        return R.layout.atydlg_choose_tip;
    }

    @Override
    public void init() {
        NumberWheelAdapter adapter = new NumberWheelAdapter(0, TIP_MAX, 1, "");
        tips.setAdapter(adapter);

        if (getIntent().hasExtra("tip")){
            int tip = getIntent().getIntExtra("tip", 0);
            tips.select(tip);
        }
    }

    @OnClick(R.id.choose_tip_ok)
    public void clickOK() {
        Intent data = new Intent();
        data.putExtra(RETURN_VALUE, tips.getCurrentItemString());
        setResult(RESULT_OK, data);
        finish();
    }

    @OnClick(R.id.choose_tip_cancle)
    public void clickCancle() {
        finish();
    }
}
